/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package canteen.sys.model.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author TNT
 */
@Entity
@Table(uniqueConstraints = {
    @UniqueConstraint( columnNames = {"itemName", "itemTypeId"})})
public class ItemMaster implements Serializable {

    @Id
    @GeneratedValue
    private int itemId;
    @NotNull
    @Size(min = 5, max = 50, message = "Name Item  must >=5 or <=50 character")
    @Column(length = 50, unique = true)
    private String itemName;
    @NotNull
    @ManyToOne
    @JoinColumn(name = "itemTypeId")
    private ItemTypeMaster itemType;
    @NotNull
    private int quantity;
    @NotNull
    private double itemRate;
    @NotNull
    private boolean status;

    public ItemTypeMaster getItemType() {
        return itemType;
    }

    public void setItemType(ItemTypeMaster itemType) {
        this.itemType = itemType;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public ItemMaster(int itemId, String itemName, double itemRate, boolean status) {
        this.itemId = itemId;
        this.itemName = itemName;
        this.itemRate = itemRate;
        this.status = status;
    }

    public ItemMaster() {
    }

    public int getItemId() {
        return itemId;
    }

    public void setItemId(int itemId) {
        this.itemId = itemId;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    public double getItemRate() {
        return itemRate;
    }

    public void setItemRate(double itemRate) {
        this.itemRate = itemRate;
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }
}
